package sz.szsmk.citizencard.mvp.presenter;

import android.util.Log;

import com.google.gson.Gson;

import javax.inject.Inject;

import sz.szsmk.citizencard.model.network.GsdxNetApi;
import sz.szsmk.citizencard.model.network.bean.request.IBaseRequest;
import sz.szsmk.citizencard.model.network.bean.response.QueryAllFunctionNewRes;
import sz.szsmk.citizencard.mvp.contract.ICareModeContact;
import sz.szsmk.citizencard.retrofitrxjava.ErrorAction;
import sz.szsmk.citizencard.retrofitrxjava.NetworkDateSources;
import sz.szsmk.citizencard.retrofitrxjava.SubscribeResult;

/**
 * Copyright (c)2021/5/21
 * author: hxh
 * created on: 2021/5/21 18:07
 * description:
 */
public class CareModePresenter extends IBasePresenter
        implements ICareModeContact.ICareModePresenter<ICareModeContact.ICareModeView> {


    private NetworkDateSources mNetworkDateSource;
    GsdxNetApi gsdxNetApi;

    @Inject
    public CareModePresenter(GsdxNetApi gsdxNetApi) {
        this.gsdxNetApi = gsdxNetApi;
        this.mNetworkDateSource = NetworkDateSources.getInstance();
    }


    @Override
    public void getViewData() {
        IBaseRequest baseRequest = new IBaseRequest();
        mNetworkDateSource.queryAllFunctionNew(baseRequest, new SubscribeResult<QueryAllFunctionNewRes>() {
            @Override
            protected void onOk(QueryAllFunctionNewRes response) {
                String json = new Gson().toJson(response);
                //Log.e("信息",json);
                ((ICareModeContact.ICareModeView) mView).getViewDataSucc(response);

            }

            @Override
            protected void onFailure(QueryAllFunctionNewRes response) {
                ((ICareModeContact.ICareModeView) mView).getViewDataFail(response);
            }

            @Override
            protected void onNext(QueryAllFunctionNewRes response) {
            }
        }, new ErrorAction() {
            @Override
            public void onCall(Throwable throwable) {

            }
        });
    }


}
